#
# Reading.py
#
"""
::BOH
$Id: reading.py,v 1.2 2006/03/31 00:00:00

Copyright (c) 2006 George Bobeck. All rights reserved.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
::EOH

Data structure for OWTF sensor readings
"""
class reading:
    def __init__(self):
        self.mid = "None" # monitor ID
        self.sid = "None" # sensor ID
        self.location = "None" # sensor location 
        self.cron = "0000-01-01 00:00:00" # Datetime Format should be YYYY-MM-DD HH:MM:SS 
        self.temp = 0.0 # temperature, OWFS default
        self.humid = 0.0 # humidity, %
        self.V1 = 0.0 # Voltage 1, extra data slot
        self.V2 = 0.0 # Voltage 2, extra data slot

    def SetMID(self,a):
        self.mid = a

    def GetMID(self):
        return self.mid

    def SetSID(self,a):
        self.sid = a

    def GetSID(self):
        return self.sid

    def SetLocation(self,a):
        self.location = a

    def GetLocation(self):
        return self.location

    def SetTime(self,a):
        self.cron = a

    def GetTime(self):
        return self.cron

    def SetTemp(self,a):
        self.temp = float(a)

    def GetTemp(self):
        return self.temp

    def SetHumid(self,a):
        self.humid = a

    def GetHumid(self):
        return self.humid

    def SetV1(self,a):
        self.V1 = a

    def GetV1(self):
        return self.V1

    def SetV2(self,a):
        self.V2 = a

    def GetV2(self):
        return self.V2

    def CtoF(self):
        cel = float( self.temp )
        ft = ( cel * ( 9.0/5.0 ) ) + 32.0
        return ft

    def FtoC(self):
        ft = float( self.temp )
        cel = ((ft - 32.0) * (5.0/9.0))
        return cel

    def CtoK(self):
        kel = self.temp + 273.18
        return kel

    def KtoC(self):
        cel = self.temp - 273.18 
        return cel
